package view;

import java.awt.*;
import javax.swing.*;

import model.Field;

/**
 * A class for the histogram.
 * 
 * @author Martin Kromkamp and Albert-Jan Boer.
 * @version 2009.01.28
 */
public abstract class StatsView extends View {
	
	// The frame which shows the histogram
	protected JFrame frame;
	// The height and width of the frame
	protected int height, width;
	// The maximum amount of an animal type
	protected int maximumAmount;
	// The height of the statisticsviewer
	protected int statsViewHeight;
	// The amount of animals per pixel on the statsviewer
	protected int amountPerPixel;
	// The amount of pixels on the left side of the histogram
	protected int pixelsLeft;
	// The field from which the histogram gets its stats
	protected Field field;


	
	public StatsView(int width, int height, int maximumAmount, Field field)
	{
		this.width = width;
		this.height = height;
		this.maximumAmount = maximumAmount;
		this.field = field;
		
		statsViewHeight = 495;
		pixelsLeft = 40;
		amountPerPixel = Math.round(maximumAmount / 500);

	}
	
	/**
	 * Creates the frame and adds the histogram to its contentPane.
	 */
	public void createFrame(String title)
	{
		frame = new JFrame(title);
		frame.setSize(width,height);
		frame.getContentPane().setBackground(Color.WHITE);		
		frame.setVisible(true);
	}
	
	/**
	 * Places the frame somewhere else on the screen.
	 * @param x The amount of pixels left of the frame.
	 * @param y The amount of pixels top of the frame.
	 */
	public void setLocation(int x, int y) {
		frame.setLocation(x, y);
	}
}
